package com.wxq.workpad.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.wxq.workpad.R
import com.wxq.workpad.entity.ProductBaseInfoEntity
import com.wxq.workpad.entity.TopTitleEntity

/**
 * @Description: 类作用描述
 */
class BaseInfoTopAdapter(context: Context):RecyclerView.Adapter<RecyclerView.ViewHolder>() {
    private var mContext:Context

    private var mData:MutableList<ProductBaseInfoEntity>
    private lateinit var listener:(position:Int)->Unit

    init {
        mContext=context
        mData= mutableListOf()
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return ItemHold(LayoutInflater.from(mContext).inflate(R.layout.item_baseinfo_top,parent,false))
    }

    override fun getItemCount(): Int {
        if (mData==null){
            return 0;
        }
        return mData.size
    }

    fun updateDate(data:MutableList<ProductBaseInfoEntity>){
        mData=data
        notifyDataSetChanged()
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        if (holder is ItemHold){

        }
    }




    fun setClickListener(itemClick:(position:Int)->Unit){
        listener=itemClick
    }


    inner class ItemHold(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var tv_attr_name:TextView
        var tv_attr_value:TextView

        init {
            tv_attr_name=itemView.findViewById(R.id.tv_attr_name)
            tv_attr_value=itemView.findViewById(R.id.tv_attr_value)

        }
    }
}